package personal.persistance.dao;

/**
 *
 * @author LocNguyen
 */
public class DaoFactory {
    private static DaoFactory instance;
    private ImageDao imgDao = null;
    private AlbumDao albumDao = null;
    private AlbumDetailDao albumDetailDao = null;
    
    private final static Object mutex = new Object();
    
    public DaoFactory() {
        //instance = new DaoFactory();
    }
    
    public static DaoFactory getInstance() {
        if (instance == null)
            instance = new DaoFactory();

        return instance;
    }
    
    public ImageDao getImageDao() {
        synchronized(mutex) {
            if (imgDao == null) {
                imgDao = new ImageDao();
            }
        
            return imgDao;
        }
    }
    
    public AlbumDao getAlbumDao() {
        synchronized(mutex) {
            if (albumDao == null) {
                albumDao = new AlbumDao();
            }
        
            return albumDao;
        }
    }
    
    public AlbumDetailDao getAlbumDetailDao() {
        synchronized(mutex) {
            if (albumDetailDao == null) {
                albumDetailDao = new AlbumDetailDao();
            }
        
            return albumDetailDao;
        }
    }
    
}
